package xyz.xtt.asset.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import xyz.xtt.asset.client.response.AssetAccountResponse;
import xyz.xtt.asset.entity.TblAssetAccount;
import xyz.xtt.asset.service.ITblAssetAccountService;
import xyz.xtt.common.objects.DozerUtil;
import xyz.xtt.common.response.ApiResult;

@Tag(name = "资产帐户管理", description = "资产帐户管理")
@Slf4j
@RequestMapping("/api/nft/asset")
@RestController
public class AccountController {

	@Autowired
	private ITblAssetAccountService iTblAssetAccountService;

	/**
	 * 某有资产的详情 检查余额
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/accountInfoCheckAmount")
	public ApiResult<AssetAccountResponse> accountInfoCheckAmount(@RequestParam("assetId") Long assetId, @RequestParam("appUid") Long appUid) {
		log.info("/api/nft/asset/accountInfoCheckAmount assetId:{},appUid:{}", assetId, appUid);
		TblAssetAccount accountNoCheckAmount = iTblAssetAccountService.account(assetId, appUid);
		AssetAccountResponse transfor = DozerUtil.transfor(accountNoCheckAmount, AssetAccountResponse.class);
		return ApiResult.ok(transfor);
	}

	/**
	 * 某有资产的详情 不检查余额
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/accountInfoUnCheckAmount")
	public ApiResult<AssetAccountResponse> accountInfoUnCheckAmount(@RequestParam("assetId") Long assetId, @RequestParam("appUid") Long appUid) {
		log.info("/api/nft/asset/accountInfoUnCheckAmount assetId:{},appUid:{}", assetId, appUid);
		TblAssetAccount accountNoCheckAmount = iTblAssetAccountService.accountNoCheckAmount(assetId, appUid);
		AssetAccountResponse transfor = DozerUtil.transfor(accountNoCheckAmount, AssetAccountResponse.class);
		return ApiResult.ok(transfor);
	}

	@GetMapping("/accountInfoWithId")
	public ApiResult<AssetAccountResponse> accountInfoWithId(@RequestParam("accountId") Long accountId) {
		log.info("/api/nft/asset/accountInfoWithId accountId:{}", accountId);
		AssetAccountResponse response = iTblAssetAccountService.accountInfoWithId(accountId);
		return ApiResult.ok(response);
	}
}
